package jianzhi

type CQueue struct {
	out []int
	in  []int
}

func Constructor09() CQueue {
	return CQueue{[]int{}, []int{}}
}

func (this *CQueue) AppendTail(value int) {
	for i := len(this.out) - 1; i >= 0; i-- {
		this.in = append(this.in, this.out[i])
		this.out = this.out[:i]
	}

	this.in = append(this.in, value)
}

func (this *CQueue) DeleteHead() int {

	if len(this.in) == 0 && len(this.out) == 0 {
		return -1
	}

	for i := len(this.in) - 1; i >= 0; i-- {
		this.out = append(this.out, this.in[i])
		this.in = this.in[:i]
	}

	val := this.out[len(this.out)-1]
	this.out = this.out[:len(this.out)-1]
	return val
}
